﻿<!DOCTYPE html>
<html>

<head>
    <title>veloClass_test</title>
    <link rel='stylesheet' href='/css/style.css' />
    <script src="/js/jquery-1.8.3.min.js"></script>
    <script src="/js/jquery.form.js"></script>
    <style>
        h3 {
            color: rgb(17, 0, 255);
            margin: 20px 0;
        }
        
        button {
            margin: 20px 0;
        }
    </style>
</head>

<body>
    <h2>班级接口</h2>
    <h3>根据老师的guid获取他的班级列表</h3>
    <div>GET /class/getClassList/:CreatorGuid?Valid=&State= </div>
    <pre>
CreatorGuid:创建人（老师）guid          
Valid:1||0||99(1：全部数据||0：没过期的数据||99:过期的数据)
State：0||99（0：没被删除的数据||99：被删除的数据,不传则返回全部的数据）
      </pre>
    <button class="getclassbystudent" onclick="api1()">.e.g</button>
    <hr>

    <h3>返回默认图片</h3>
    <div>GET /class/defaultCover </div>
    <button class="getclassbystudent" onclick="api2()">.e.g</button>
    <hr>
    <h3>删除或恢复班级 </h3>
    <div>put /class/:PK_ClassGuid </div>
    <pre>
        {
            State:0||99(0:恢复,99:删除)
        }
    </pre>
    <button class="getclassbystudent" onclick="api3()">.e.g</button>
    <hr>

    <h3>上传封面</h3>
    <div>post /class/cover </div>
    <form enctype="multipart/form-data" class="upload-class">
        <input type="file" name="uploadimg" onchange="uploadClassCover()">
    </form>
    <hr>

    <h3>上传富文本图片</h3>
    <div>post /class/img </div>
    <form enctype="multipart/form-data" class="upload-class2">
        <input type="file" name="uploadimg" onchange="uploadClassCover2()">
    </form>
    <hr>

    <h3>添加班级</h3>
    <div>post /class/addclass </div>
    <pre>
       {
        className: '',
        inviteCode:'邀请码' ,
        endTime: '结束时间',
        creatorGuid: '创建人（老师）guid',
        coverUrl: '封面'
       }
       
   </pre>
    <hr>

    <h3>编辑班级</h3>
    <div>post /class/putclass </div>
    <pre>
       {
        PK_ClassGuid：'''
        className: '',
        inviteCode:'邀请码' ,
        endTime: '结束时间',
        coverUrl: '封面'
       }
   </pre>
    <button class="edit">。e.g</button>
    <hr>
    <h3>获取指定GUID班级</h3>
    <div>get /class/private/classListString= </div>
    <pre>
classListString:班级guid（可传列表）      
   </pre>
    <button class="getclassbystudent" onclick="api4()">.e.g</button>
    <hr>

    <h2>通知接口</h2>
    <button class="add-notice">添加通知</button>
    <button class="del-notice">删除通知</button>
    <button class="re-notice">恢复通知</button>
    <button class="put-notice">修改通知</button>

    <h3>获取通知列表</h3>
    <div>GET /notice?calss=&index=&num=&state= </div>
    <pre>
            calss:'班级guid'，
            index:'从第几条数据开始获取，默认0',
            num:'获取多少条数据,默认100000',
            state:0||99
    </pre>
    <button class="get-notice-list">e.g</button>
    <hr>

    <h2>成绩接口</h2>
    <h3></h3>
    <div>get </div>
    <pre>
    </pre>
    <button class="" onclick="">.e.g</button>
    <hr>


    <h2>成绩环节接口</h2>
    <h3>根据班级guid获取成绩环节</h3>
    <div>get /scoresegment/list/:classGuid</div>
    <pre>
    </pre>
    <button class="getScoreSegmentList" onclick="getScoreSegmentList()">.e.g</button>
    <hr>


    <h2>学生端班级接口</h2>
    <h3>获取当前所有可用班级列表</h3>
    <div>GET class/all </div>
    <pre>
        Valid:1||0||99(1：全部数据||0：没过期的数据||99:过期的数据)
   </pre>
    <button class="getclassbystudent" onclick="api5()">.e.g</button>
    <hr>

    <h3>搜索班级</h3>
    <div>GET class/search?searchText=&n=&m=& </div>
    <pre>
            index: 从第几条数据开始获取，默认0,
            num: 获取多少条数据,默认100000,
            searchText: '邀请码或班级名字或老师名字(模糊查询)'
   </pre>
    <button class="getclassbystudent" onclick="api6()">.e.g</button>
    <hr>

    <h3>加入班级</h3>
    <div>GET class/join</div>
    <pre>{
            InvitationCode：邀请码,
            FK_UserGuid:'',
            FK_ClassGuid:''
        }
   </pre>
    <button class="getclassbystudent" onclick="api7()">.e.g</button>
    <hr>
    <h3>已读</h3>
    <div>post /notice/read</div>
    <pre>{
        FK_NoticeGuid:'',
        FK_UserGuid:''
        }
   </pre>
    <button class="getclassbystudent" onclick="api9()">.e.g</button>
    <hr>

    <h3>用学生guid获取通知列表</h3>
    <div>get /notice/getNoticeByUser</div>
    <pre>{
        FK_ClassGuid:'',
        FK_UserGuid:'',
        state:0||99    (0:'正常的通知',99:'被删除的通知')
        }
   </pre>
    <button class="getclassbystudent" onclick="api8()">.e.g</button>
    <hr>


    <h3>是否有未读</h3>
    <div>get /notice/Unread</div>
    <pre>{
        FK_ClassGuid:'',
        FK_UserGuid:'',
        }
   </pre>
    <button class="getclassbystudent" onclick="api10()">.e.g</button>
    <hr>
</body>
<script>
    function api1() {
        $.get('/class/getClassList/3ab74e91-c34f-499d-9711-166e423d4dd6?Valid=1&State=0', function(re) {
            console.log(re)
        })
    }

    function api2() {
        $.get('/class/defaultCover', function(re) {
            console.log(re)
        })
    }

    function api3() {
        $.ajax({
            type: "put",
            url: "/class/8e70a3ae-d606-4070-9599-988ad3c1a97a",
            data: {
                State: 0
            },
            success: function(response) {
                console.log(response);
            }
        });
    }

    function api4() {
        $.ajax({
            type: "get",
            url: "/class/private",
            data: {
                classListString: '"9603f636-0d1c-4eba-8dce-479dc1fbf4e4", "7dd1f6c5-e826-44f2-98cb-ca562e150ef4"'
            },
            success: function(response) {
                console.log(response);
            }
        });
    }

    function uploadClassCover() {
        $('.upload-class').ajaxSubmit({
            url: '/class/cover',
            type: "post",
            success: function(path) {
                console.log(path);
            },
            error: function() {
                console.log('err');
            }
        })
    }

    function uploadClassCover2() {
        $('.upload-class2').ajaxSubmit({
            url: '/class/img',
            type: "post",
            success: function(path) {
                console.log(path);
            },
            error: function() {
                console.log('err');
            }
        })
    }

    $('.add-notice').click(function() {
        $.ajax({
            type: "post",
            url: "/notice",
            data: {
                title: '通知通知2222',
                content: '通知明天不上课22222！！！',
                object: '456',
                classGuid: '098bbfd6-53b0-486b-b64b-c92a604eae98'
            },
            success: function(response) {
                console.log(response);
            }
        });
    });
    $('.del-notice').click(function() {
        $.ajax({
            type: "delete",
            url: "/notice/1f8f9367-1c1b-4e60-863e-85e7c27402ac",
            success: function(response) {
                console.log(response);
            }
        });
    });
    $('.re-notice').click(function() {
        $.ajax({
            type: "put",
            url: "/notice/recovery/1f8f9367-1c1b-4e60-863e-85e7c27402ac",
            success: function(response) {
                console.log(response);
            }
        });
    });
    $('.put-notice').click(function() {
        $.ajax({
            type: "put",
            url: "/notice/2e969cc3-221f-42f8-8671-7de4cbe1c581",
            data: {
                title: '通知通知333',
                content: '通知明天不上课3333！！！',
                object: '456'
            },
            success: function(response) {
                console.log(response);
            }
        });
    });
    $('.get-notice-list').click(function() {
        $.ajax({
            type: "get",
            url: "/notice?class=9603f636-0d1c-4eba-8dce-479dc1fbf4e4",
            success: function(response) {
                console.log(response);
            }
        });
    });

    function api5() {
        $.get("/class/all?Valid=1", function(re) {
            console.log(re);
        })
    }

    function api6() {
        $.get("/class/search?searchText=张&FK_UserGuid=ba903b5a-0520-2566-45eb-5674e3ae6cf7", function(re) {
            console.log(re);
        })
    }

    function api7() {
        $.post("/class/join", {
            InvitationCode: 820051,
            FK_UserGuid: 'ba903b5a-0520-2566-45eb-5674e3ae6cf7',
            FK_ClassGuid: '85a0a39e-5f22-4d07-a570-18d936e07b13'
        }, function(re) {
            console.log(re);
        })
    }

    function api8() {
        $.get("/notice/getNoticeByUser?FK_ClassGuid=852dca73-17a0-4973-8b28-3782332bc697&FK_UserGuid=ba903b5a-0520-2566-45eb-5674e3ae6cf7", function(re) {
            console.log(re);
        })
    }

    function api9() {
        $.ajax({
            type: "post",
            url: "/notice/read",
            data: {
                FK_NoticeGuid: '6ed5fd63-e668-463d-b634-5e6b1748b0bf',
                FK_UserGuid: '8a525c72-9fb1-b12f-9332-8c138c2e85f2',
            },
            success: function(response) {
                console.log(response);
            }
        });
    }

    function api10() {
        $.get("/notice/Unread?FK_ClassGuid=852dca73-17a0-4973-8b28-3782332bc697&FK_UserGuid=ba903b5a-0520-2566-45eb-5674e3ae6cf7", function(re) {
            console.log(re);
        })
    }

    function getScoreSegmentList() {
        $.get("/scoresegment/list/852dca73-17a0-4973-8b28-3782332bc697", function(re) {
            console.log(re);
        })
    }
</script>

</html>